import React from "react";
import { Button, Input, Form } from "react-vant";
import {useNavigate} from 'react-router-dom'
import axios from "axios";
import { message } from "antd";
import { NavLink } from "react-router-dom";
const Index: React.FC = () => {
  const [form] = Form.useForm();
  const navigate=useNavigate()

  const onFinish = (values: any) => {
    axios.post('/api/sigin',values).then((resp)=>{
      let {code,msg}=resp.data
      if (code==200) {
        message.success(msg)
        navigate('/login')
      }
    })
  };
  return (
    <div>
      <h3>维度医疗注册</h3>
      <Form
        form={form}
        onFinish={onFinish}
        footer={
          <div style={{ margin: "16px 16px 0" }}>
            <Button round nativeType="submit" type="primary" block>
              注册
            </Button>
          </div>
        }
      >
        <Form.Item
          tooltip={{
            message:
              "A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself.",
          }}
          rules={[{ required: true, message: "请填写账号" }]}
          name="username"
          label="用户名"
        >
          <Input placeholder="请输入注册的用户名" />
        </Form.Item>
        <Form.Item
          rules={[{ required: true, message: "请填写密码" }]}
          name="password"
          label="密码"
        >
          <Input placeholder="请输入注册的密码" />
        </Form.Item>
      </Form>
    </div>
  );
};
export default Index;
